package com.comm.ui.main;

import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.ListView;

import com.comm.MainApplication;
import com.comm.R;
import com.comm.base.BaseActivity;
import com.comm.module.bean.EventInfo;
import com.comm.ui.widget.MultipleStatusView;

import java.util.List;

public class MainActivity extends BaseActivity implements Mainconstant.View {

    private MultipleStatusView statusView;
    private EventInfoAdapter adapter;

    @Override
    protected void init(Bundle savedInstanceState) {
        imContext.createMainController(this);
        statusView = (MultipleStatusView) findViewById(R.id.status_view);
        ListView listView = (ListView) LayoutInflater.from(this).inflate(R.layout.main_list_layout, null);
        statusView.setContentView(listView);
        adapter = new EventInfoAdapter(this);
        listView.setAdapter(adapter);
    }

    @Override
    protected int getContentLayout() {
        return R.layout.activity_main;
    }

    @Override
    public MainApplication getImContext() {
        return (MainApplication) getApplication();
    }

    @Override
    public Activity getActivity() {
        return this;
    }

    @Override
    public void setController(Mainconstant.Controller controller) {
        this.controller = controller;
    }

    @Override
    public void showProgressView() {
        statusView.showLoading();
    }

    @Override
    public void showEmptyView() {
        statusView.showEmpty();
    }

    @Override
    public void showErrorView() {
        statusView.showError();
    }

    @Override
    public void showContent(List<EventInfo> eventInfos) {
        statusView.showContent();
        adapter.setData(eventInfos);
    }
}
